let gatewayUrl = "";

/**
 * 用于让前端页面判断自己是在程序中还是静态页面中
 * @returns {boolean} 是否在Java程序中运行
 */
function inThymeleaf() {
    return "undefined" != typeof _InThymeleaf && _InThymeleaf === true;
}

//http://shenbao.sp.renfei.net:18888
$(document).ready(function () {
    if (inThymeleaf()) {
        gatewayUrl = "";
    } else {
        gatewayUrl = "/api";
    }
});

function setStore(name, content) {
    if (window.localStorage) {
        window.localStorage.setItem(name, content);
    } else {
        alert('此浏览器不支持「LocalStorage」技术,请更换浏览器尝试');
    }
}

// 获取 localstorage 中的值,判断用户是否登录
function getStore(name) {
    if (window.localStorage) {
        return window.localStorage.getItem(name);
    } else {
        alert('此浏览器不支持「LocalStorage」技术,请更换浏览器尝试');
    }
}

function removeStore(name) {
    if (window.localStorage) {
        window.localStorage.removeItem(name);
    } else {
        alert('此浏览器不支持「LocalStorage」技术,请更换浏览器尝试');
    }
}

// 生成秘钥对
function generateKey() {
    let keySize = 1024;
    let crypt = new JSEncrypt({ default_key_size: keySize });
    crypt.getKey();
    setStore('ClientPublicKey', crypt.getPublicKey().replace("-----BEGIN PUBLIC KEY-----\n", "").replace("\n-----END PUBLIC KEY-----", ""));
    setStore('ClientPrivateKey', crypt.getPrivateKey().replace("-----BEGIN PRIVATE KEY-----\n", "").replace("\n-----END PRIVATE KEY-----", ""));
}

// 获取客户端公钥
function getClientPublicKey() {
    let key = getStore("ClientPublicKey");
    if (key === null || key === undefined) {
        generateKey();
    }
    return getStore("ClientPublicKey");
}

// 获取AES秘钥
function getAESKey() {
    let key = getStore("aesKey");
    let keys = {};
    // 如果Store里没有那么就去申请
    if (key === null || key === undefined) {
        let ok = false;
        let reportPublicKeyVO = {};
        // 获取服务器端公钥
        $.ajax({
            url: gatewayUrl + '/core/secretkey',
            type: 'GET',
            async: false,
            data: {},
            timeout: 5000,
            dataType: 'json',
            success: function (data, textStatus) {
                if (data.code !== 200) {
                    errmsg('错误', "申请加密公钥服务发生错误", "请联系管理员");
                } else {
                    let serverPublicKey = data.data;
                    let serverPublicKeyId = data.message;
                    // 使用服务器端公钥加密客户端公钥，注意服务器端公钥是2048，客户端公钥是1024
                    let jse = new JSEncrypt();
                    jse.setPublicKey(serverPublicKey);
                    let clientEncryptPublicKey = jse.encrypt(getClientPublicKey());
                    reportPublicKeyVO.secretKeyId = serverPublicKeyId;
                    reportPublicKeyVO.publicKey = clientEncryptPublicKey;
                    ok = true;
                }
            },
            error: function (xhr, textStatus, errorThrown) {
                errmsg('错误', xhr.responseText, "请求发生了异常，请联系管理员");
                console.log('错误', xhr.responseText);
                console.log(xhr);
                console.log(textStatus);
            }
        });
        if (ok) {
            // 将加密好的客户端公钥上报给服务器
            $.ajax({
                url: gatewayUrl + '/core/secretkey',
                type: 'POST',
                async: false,
                data: JSON.stringify(reportPublicKeyVO),
                contentType: 'application/json;charset=UTF-8',
                timeout: 5000,
                dataType: 'json',
                success: function (serverRes, textStatus) {
                    if (serverRes.code !== 200) {
                        errmsg('错误', "上报公钥服务发生错误", "请联系管理员");
                    } else {
                        // 用客户端私钥解密服务器返回的AES秘钥
                        let jse = new JSEncrypt();
                        jse.setPrivateKey('-----BEGIN PRIVATE KEY-----\n' +
                            getStore("ClientPrivateKey") +
                            '\n-----END PRIVATE KEY-----\n');
                        let aesKey = jse.decrypt(serverRes.data.aeskey);
                        let keys = {};
                        keys.aesKey = aesKey;
                        keys.aesKeyId = serverRes.data.keyid;
                        // 存储下来 AES 秘钥，现在这个秘钥全世界只有你知和我知，不要公开，不要在网络上明文传输
                        setStore("aesKey", aesKey);
                        setStore("aesKeyId", serverRes.data.keyid);
                        return keys;
                    }
                },
                error: function (xhr, textStatus, errorThrown) {
                    errmsg('错误', xhr.responseText, "请求发生了异常，请联系管理员");
                    console.log('错误', xhr.responseText);
                    console.log(xhr);
                    console.log(textStatus);
                }
            });
        }
    } else {
        keys.aesKey = getStore("aesKey");
        keys.aesKeyId = getStore("aesKeyId");
        return keys;
    }
}

//加密
function aesencrypt(word) {
    getAESKey();
    let aesKey = getAESKey().aesKey;
    let key = CryptoJS.enc.Utf8.parse(aesKey);
    let iv = CryptoJS.enc.Utf8.parse(aesKey);
    let srcs = CryptoJS.enc.Utf8.parse(word);
    let encrypted = CryptoJS.AES.encrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
    return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
    // return CryptoJS.AES.encrypt(word,getAESKey()).toString()
}

//解密getAESKey
function aesdecrypt(word) {
    getAESKey()
    let aesKey = getAESKey().aesKey;
    let key = CryptoJS.enc.Utf8.parse(aesKey);//Latin1 w8m31+Yy/Nw6thPsMpO5fg==
    let decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
    // return CryptoJS.AES.decrypt(word,getAESKey()).toString(CryptoJS.enc.Utf8);
}

function msg(title, content, describe) {
    $(".msg_title").text(title);
    $(".msg_content").text(content);
    $(".msg_describe").text(describe);
    $('.success').show().addClass('animate');
}

function errmsg(title, content, describe) {
    $(".msg_title").text(title);
    $(".msg_content").text(content);
    $(".msg_describe").text(describe);
    $('.error').show().addClass('animate');
}

function closemsg() {
    $('.success').hide().removeClass('animate');
    $('.error').hide().removeClass('animate');
}

function signing() {
    console.log(1231232131231231231)
    // 登录判断 登录拦截开启需要注释掉
    // localStorage.setItem("aesKey", "wo37p6tLVmRxz6n2");
    let verificationCode = $("#verificationCode").val();
    let name = $("#username").val();
    let mypassword = $("#password").val();
    let grant_type = "auto_password";
    let client_id = "Browser";
    let client_secret = $("#uuid").val();
    let language = "zh-CN";
    if (verificationCode.length !== 4) {
        alert("请填写正确的验证码");
        errmsg("错误", "请填写正确的验证码", "验证码为4位")
        return;
    }
    if (name.length < 1) {
        alert("您似乎没有填写账号");
        errmsg("错误", "您似乎没有填写账号", "请填写正确的账号")
        return;
    }
    if (mypassword.length < 1) {
        alert("您似乎没有填写密码");
        errmsg("错误", "您似乎没有填写密码", "请填写正确密码")
        return;
    }
    $("#signinbtn").text("登录中..");
    // let password = aesencrypt(mypassword);
    // let keyid = getStore("aesKeyId");
    let data = {};
    data.code = verificationCode;
    data.username = name;
    // data.password = password;
    data.password = mypassword;
    data.grant_type = grant_type;
    data.client_id = client_id;
    data.uuid = client_secret;
    data.language = language;
    // data.keyid = keyid;
    $.ajax({
        // url: gatewayUrl + '/report/SignIn',
        url: 'http://localhost:10010/api/login',
        type: 'POST',
        async: false,
        contentType: 'application/json;charset=UTF-8',
        data: JSON.stringify(data),
        timeout: 5000,
        dataType: 'json',
        success: function (serverRes, textStatus) {
            if (serverRes.code !== 200) {
                alert(serverRes.message);
                errmsg('错误', serverRes.message, "");
                $("#signinbtn").text("登 录");
            } else {
                // 登录成功
                if (inThymeleaf()) {
                    if (window.location.href.indexOf("from=") !== -1) {
                        let linkUrl = getParamter("from=");
                        window.location.href = linkUrl;
                    } else {
                        window.location.href = "/report"
                    }
                } else {
                    window.location.href = "../../templates/index.ftl"
                }
            }
        },
        error: function (xhr, textStatus, errorThrown) {
            $("#signinbtn").text("登 录");
            alert("请求发生了异常，请联系管理员");
            errmsg('错误', xhr.statusText, "请求发生了异常，请联系管理员");
            console.log('错误', xhr.responseText);
            console.log(xhr);
            console.log(textStatus);
        }
    });
}

function signin2() {
    let verificationCode = $("#verificationCode2").val();
    let name = $("#sjhm").val();
    let mypassword = $("#dx").val();
    let grant_type = "verification_code";
    let client_id = "Browser";
    let client_secret = "w4nHQGH8oBsj4HMrgcYVyZRFPFbMUuLK";
    let language = "zh-CN";
    // if (verificationCode.length !== 4) {
    //     alert("请填写正确的验证码");
    //     errmsg("错误", "请填写正确的验证码", "验证码为4位")
    //     return;
    // }

    if (name.length < 1) {
        alert("您似乎没有填写账号");
        errmsg("错误", "您似乎没有填写账号", "请填写正确的账号")
        return;
    }
    if (mypassword.length < 1) {
        alert("您似乎没有填写密码");
        errmsg("错误", "您似乎没有填写密码", "请填写正确密码")
        return;
    }
    $("#signinbtn").text("登录中..");
    let password = aesencrypt(mypassword);
    let keyid = getStore("aesKeyId");
    let data = {};
    data.verificationCode = verificationCode;
    data.name = name;
    data.password = password;
    data.grant_type = grant_type;
    data.client_id = client_id;
    data.client_secret = client_secret;
    data.language = language;
    data.keyid = keyid;
    $.ajax({
        url: gatewayUrl + '/report/SignIn',
        type: 'POST',
        async: false,
        contentType: 'application/json;charset=UTF-8',
        data: JSON.stringify(data),
        timeout: 5000,
        dataType: 'json',
        success: function (serverRes, textStatus) {
            if (serverRes.code !== 200) {
                alert(serverRes.message);
                errmsg('错误', serverRes.message, "");
                $("#signinbtn").text("登 录");
            } else {
                // 登录成功
                if (inThymeleaf()) {
                    if (window.location.href.indexOf("from=") != -1) {
                        let linkUrl = getParamter("from=");
                        window.location.href = linkUrl;
                    } else {
                        window.location.href = "/report"
                    }
                } else {
                    window.location.href = "../../templates/index.ftl"
                }
            }
        },
        error: function (xhr, textStatus, errorThrown) {
            $("#signinbtn").text("登 录");
            alert("请求发生了异常，请联系管理员");
            errmsg('错误', xhr.statusText, "请求发生了异常，请联系管理员");
            console.log('错误', xhr.responseText);
            console.log(xhr);
            console.log(textStatus);
        }
    });
}

function SignOut() {
    if (confirm("确定登出系统吗？")) {
        $.ajax({
            url: gatewayUrl + '/report/SignOut',
            type: 'GET',
            async: false,
            contentType: 'application/json;charset=UTF-8',
            timeout: 5000,
            dataType: 'json',
            success: function (serverRes, textStatus) {
                if (serverRes.code !== 200) {
                    errmsg('错误', serverRes.message, "");
                } else {
                    if (inThymeleaf()) {
                        window.location.href = "/report"
                    } else {
                        window.location.href = "../../templates/index.ftl"
                    }
                }
            },
            error: function (xhr, textStatus, errorThrown) {
                errmsg('错误', xhr.statusText, "请求发生了异常，请联系管理员");
                console.log('错误', xhr.responseText);
                console.log(xhr);
                console.log(textStatus);
            }
        });
    }
}


$(function () {
    // 刷新验证码
    $("#verificationCodeImg").bind("click", function () {
        $(this).hide().attr('src', '/report/verificationCode?').fadeIn();
    });
});

//刷新验证码
function updateCodeImg() {
    $("#verificationCodeImgIndex").hide().attr('src', '/report/verificationCode?').fadeIn();
}

$(document).ready(function () {
    // footer页脚位置的设置
    controllFooter();

    function controllFooter() {
        if ($(window).height() < $(document).height()) {
            $(".footer").css('position', 'static');
        } else {
            $(".footer").css({ 'position': 'fixed', 'bottom': '0px' });
        }
    }

    $(".form_datetime").datepicker({
        //显示年
        language: 'zh-CN',
        startView: 'decade',
        endView: 'decade',
        maxViewMode: 'decade',
        minViewMode: 'decade',
        format: 'yyyy',
        autoclose: true,
        todayHighlight: true
    })

});


zTreeNodes = [
    { "id": "540000", "pId": null, "name": "西藏自治区" },
    { "id": "540100", "pId": "540000", "name": "拉萨市" },
    { "id": "540102", "pId": "540100", "name": "城关区" },
    { "id": "540121", "pId": "540100", "name": "林周县" },
    { "id": "540122", "pId": "540100", "name": "当雄县" },
    { "id": "540123", "pId": "540100", "name": "尼木县" },
    { "id": "540124", "pId": "540100", "name": "曲水县" },
    { "id": "540125", "pId": "540100", "name": "堆龙德庆县" },
    { "id": "540126", "pId": "540100", "name": "达孜县" },
    { "id": "540127", "pId": "540100", "name": "墨竹工卡县" },
    { "id": "540128", "pId": "540100", "name": "经济技术开发区" },
    { "id": "540129", "pId": "540100", "name": "柳梧新区" },
    { "id": "540130", "pId": "540100", "name": "文化创意园区" },
    { "id": "540131", "pId": "540100", "name": "空港新区" },
    { "id": "540200", "pId": "540000", "name": "日喀则市" },
    { "id": "540202", "pId": "540200", "name": "桑珠孜区" },
    { "id": "540221", "pId": "540200", "name": "南木林县" },
    { "id": "540222", "pId": "540200", "name": "江孜县" },
    { "id": "540223", "pId": "540200", "name": "定日县" },
    { "id": "540224", "pId": "540200", "name": "萨迦县" },
    { "id": "540225", "pId": "540200", "name": "拉孜县" },
    { "id": "540226", "pId": "540200", "name": "昂仁县" },
    { "id": "540227", "pId": "540200", "name": "谢通门县" },
    { "id": "540228", "pId": "540200", "name": "白朗县" },
    { "id": "540229", "pId": "540200", "name": "仁布县" },
    { "id": "540230", "pId": "540200", "name": "康马县" },
    { "id": "540231", "pId": "540200", "name": "定结县" },
    { "id": "540232", "pId": "540200", "name": "仲巴县" },
    { "id": "540233", "pId": "540200", "name": "亚东县" },
    { "id": "540234", "pId": "540200", "name": "吉隆县" },
    { "id": "540235", "pId": "540200", "name": "聂拉木县" },
    { "id": "540236", "pId": "540200", "name": "萨嘎县" },
    { "id": "540237", "pId": "540200", "name": "岗巴县" },
    { "id": "540300", "pId": "540000", "name": "昌都市" },
    { "id": "540302", "pId": "540300", "name": "卡若区" },
    { "id": "540321", "pId": "540300", "name": "江达县" },
    { "id": "540322", "pId": "540300", "name": "贡觉县" },
    { "id": "540323", "pId": "540300", "name": "类乌齐县" },
    { "id": "540324", "pId": "540300", "name": "丁青县" },
    { "id": "540325", "pId": "540300", "name": "察雅县" },
    { "id": "540326", "pId": "540300", "name": "八宿县" },
    { "id": "540327", "pId": "540300", "name": "左贡县" },
    { "id": "540328", "pId": "540300", "name": "芒康县" },
    { "id": "540329", "pId": "540300", "name": "洛隆县" },
    { "id": "540330", "pId": "540300", "name": "边坝县" },
    { "id": "540400", "pId": "540000", "name": "林芝市" },
    { "id": "540402", "pId": "540400", "name": "巴宜区" },
    { "id": "540421", "pId": "540400", "name": "工布江达县" },
    { "id": "540422", "pId": "540400", "name": "米林县" },
    { "id": "540423", "pId": "540400", "name": "墨脱县" },
    { "id": "540424", "pId": "540400", "name": "波密县" },
    { "id": "540425", "pId": "540400", "name": "察隅县" },
    { "id": "540426", "pId": "540400", "name": "朗县" },
    { "id": "542200", "pId": "540000", "name": "山南地区" },
    { "id": "542221", "pId": "542200", "name": "乃东县" },
    { "id": "542222", "pId": "542200", "name": "扎囊县" },
    { "id": "542223", "pId": "542200", "name": "贡嘎县" },
    { "id": "542224", "pId": "542200", "name": "桑日县" },
    { "id": "542225", "pId": "542200", "name": "琼结县" },
    { "id": "542226", "pId": "542200", "name": "曲松县" },
    { "id": "542227", "pId": "542200", "name": "措美县" },
    { "id": "542228", "pId": "542200", "name": "洛扎县" },
    { "id": "542229", "pId": "542200", "name": "加查县" },
    { "id": "542231", "pId": "542200", "name": "隆子县" },
    { "id": "542232", "pId": "542200", "name": "错那县" },
    { "id": "542233", "pId": "542200", "name": "浪卡子县" },
    { "id": "542400", "pId": "540000", "name": "那曲地区" },
    { "id": "542421", "pId": "542400", "name": "那曲县" },
    { "id": "542422", "pId": "542400", "name": "嘉黎县" },
    { "id": "542423", "pId": "542400", "name": "比如县" },
    { "id": "542424", "pId": "542400", "name": "聂荣县" },
    { "id": "542425", "pId": "542400", "name": "安多县" },
    { "id": "542426", "pId": "542400", "name": "申扎县" },
    { "id": "542427", "pId": "542400", "name": "索县" },
    { "id": "542428", "pId": "542400", "name": "班戈县" },
    { "id": "542429", "pId": "542400", "name": "巴青县" },
    { "id": "542430", "pId": "542400", "name": "尼玛县" },
    { "id": "542431", "pId": "542400", "name": "双湖县" },
    { "id": "542500", "pId": "540000", "name": "阿里地区" },
    { "id": "542521", "pId": "542500", "name": "普兰县" },
    { "id": "542522", "pId": "542500", "name": "札达县" },
    { "id": "542523", "pId": "542500", "name": "噶尔县" },
    { "id": "542524", "pId": "542500", "name": "日土县" },
    { "id": "542525", "pId": "542500", "name": "革吉县" },
    { "id": "542526", "pId": "542500", "name": "改则县" },
    { "id": "542527", "pId": "542500", "name": "措勤县" }
];
var zTreeObj, zTreeObj1, zTreeObj2, zTreeObj3, zTreeObj4, zTreeObj6,
setting = {
    view: {
        selectedMulti: false
    },
    check: {
        enable: true,
        chkboxType: { "Y": "p", "N": "s" }
    },
    callback: {
        onCheck: zTreeOnCheck,
    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pid",
            rootPId: 0,
        }
    }
}
setting2 = {
    view: {
        selectedMulti: false
    },
    check: {
        enable: false,
        chkboxType: { "Y": "", "N": "s" }
    },
    callback: {
        onClick: zTreeOnClick
    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pid",
            rootPId: 0,
        }
    }
}
setting3 = {
    view: {
        selectedMulti: false
    },
    check: {
        enable: false,
        chkboxType: { "Y": "p", "N": "s" }
    },
    callback: {
        onCheck: zTreeOnCheck,
        onClick: zTreeOnClickregion
    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pid",
            rootPId: 0,
        }
    }
}
setting4 = {
    view: {
        selectedMulti: false
    },
    check: {
        enable: true,
        chkboxType: { "Y": "p", "N": "s" }
    },
    callback: {
        onCheck: zTreeOnCheck1,
    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pid",
            rootPId: 0,
        }
    }
}
setting6 = {
    view: {
        selectedMulti: false
    },
    check: {
        enable: false,
        chkboxType: { "Y": "p", "N": "s" }
    },
    callback: {
        onCheck: zTreeOnCheck,
        onClick: zTreeOnClick
    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pid",
            rootPId: 0,
        }
    }
}
//获取返回的数据，进行预操作，treeId是treeDemo,异步加载完之后走这个方法，responseData为后台返回数据
function filter(treeId, parentNode, responseData) {
//        responseData = responseData.jsonArray;
    if (!responseData.data){
        return null;
    }
    return responseData.data;
}

setting7 = {
    view: {
        selectedMulti: false
    },
    check: {
        enable: false,
        chkboxType: { "Y": "", "N": "s" }
    },
    callback: {
        onClick: zTreeOnClickCY

    },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pid",
            rootPId: 0,
        },
        keep: {
            parent: true
        },
        key: {
            isParent: "isParent"
        }
    }
}

$(document).ready(function () {
    //审批目录级别树
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/region",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj5 = $.fn.zTree.init($("#spmltree"), setting4, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    //建设地点树
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/region",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj = $.fn.zTree.init($("#citytree"), setting, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    //国际行业树
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/hydm/tree",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj1 = $.fn.zTree.init($("#gjhytree"), setting2, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    // TODO 所属行业树
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/sshy/tree",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj2 = $.fn.zTree.init($("#sshytree"), setting2, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    /*//产业结构调整指导目录树
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/cyjgtzzdml/tree",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj3 = $.fn.zTree.init($("#cyjgtree"), setting2, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });*/
    //产业结构调整指导目录树获取一级目录
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/industrial/tree?codeValue=null",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj3 = $.fn.zTree.init($("#cyjgtree"), setting7, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    // 获取西藏的行政区划zTree数据
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/region",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj4 = $.fn.zTree.init($("#citytree1"), setting3, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    //所属领域数
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/ssly/tree",
        success: function (res, status) {
            if (res.code === 200) {
                zTreeObj6 = $.fn.zTree.init($("#sslytree"), setting6, res.data);
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    //默认展开第一级节点
    zTreeObj.expandNode(zTreeObj.getNodes()[0], true, false, false);
    zTreeObj1.expandNode(zTreeObj1.getNodes()[0], true, false, false);
    zTreeObj2.expandNode(zTreeObj2.getNodes()[0], true, false, false);
    zTreeObj3.expandNode(zTreeObj3.getNodes()[0], true, false, false);


    // 默认展开两级节点
    zTreeObj4.expandNode(zTreeObj4.getNodes()[0], true, false, true);
    // 审批目录
    zTreeObj5.expandNode(zTreeObj5.getNodes()[0], true, false, true);
    zTreeObj6.expandNode(zTreeObj6.getNodes()[0], true, false, false);
});

//动态获取当前点击的目录的下级产业结构调整目录
function getNextNodeCyjctzml(categoryCodeValue){
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/industrial/tree?codeValue="+categoryCodeValue,
        success: function (res, status) {
            if (res.code === 200) {
                return res.data;
            } else {
                alert(res.message);
                return [];
            }
        },
    });
}

//选择建设地点树节点
function zTreeOnCheck(event, treeId, treeNode) {

    var jsddArr = [];
    $('#jsdd').text("")
    // $("#" + treeId + "Conten").text("");
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    //获取所有选择的节点
    var nodes = treeObj.getCheckedNodes(true);
    var cityStr = "";
    for (var i = 0; i < nodes.length; i++) {
        if (nodes[i].level == 0) {
            cityStr += nodes[i].name + ":";
        } else {
            if (nodes[i + 1] != undefined) {
                if (nodes[i + 1].level == 2) {
                    cityStr += nodes[i].name + "_";
                } else {
                    cityStr += nodes[i].name + "/";
                }
            } else {
                cityStr += nodes[i].name;
            }
            if (nodes[i].pid == "540000") {
                jsddArr.push(nodes[i].id)
            }
        }
    }
    if (nodes.length == 1) {
        jsddArr.push("540000")
    } else {
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].pid != "540000") {
                for (var j = 0; j < jsddArr.length; j++) {
                    if (jsddArr[j] == nodes[i].pid) {
                        jsddArr.splice(j);
                    }
                }
                jsddArr.push(nodes[i].id)


            }

        }


    }
    $("#jsddStr").val(cityStr)
    $("#jsdd").attr("value", jsddArr.toString())
    // $("#jsdd").attr("value", treeNode.id)
    // $("#" + treeId + "Conten").append(cityStr);
};

//修改url路径中审批目录级别的值 :替换指定传入参数的值,paramName为参数,replaceWith为新值
function replaceParamVal(paramName, replaceWith) {
    var oUrl = this.location.href.toString();
    var re = eval('/(' + paramName + '=)([^&]*)/gi');
    var nUrl = oUrl.replace(re, paramName + '=' + replaceWith);
    this.location = nUrl;
}
// 审批目录级别
function zTreeOnCheck1(event, treeId, treeNode) {
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    if (treeNode.checked) {    //注意，这里的树节点的checked状态表示勾选之后的状态
        treeObj.checkAllNodes(false);//取消所有节点的选中状态
        treeObj.checkNode(treeNode, true, false, false); //重新选中被勾选的节点
    }
    $("#spmljbStr").val(treeNode.name)
    $("#spmljb").attr("value", treeNode.id)
    // replaceParamVal("divisionName", treeNode.name)
    setStore("divisionName", treeNode.name);
};
//选择国际行业——所属行业——产业结构调整指导目录树节点
var allNodesStr = "";

//产业结构调整目录点击节点
function zTreeOnClickCY(event, treeId, treeNode){
    //console.log("isParent"+treeNode.isParent);
    //console.log(+treeNode);
    $.ajax({
        type: "GET",
        async: true,
        url: gatewayUrl + "/report/dictionary/category/industrial/tree?codeValue="+treeNode.id,
        success: function (res, status) {
            var treeObj = $.fn.zTree.getZTreeObj(treeId);
            if (res.code === 200) {
                if(res.data.length>0){

                    treeObj.removeChildNodes(treeNode);
                    treeObj.addNodes(treeNode, res.data);

                    // ------------------------------
                    var nodes = treeObj.getSelectedNodes();
                    if (nodes[0].level != 0) {
                        if (nodes.length > 0) {
                            var allNode = nodes[0]['name'];
                            //获取当前选中节点
                            var node = nodes[0].getParentNode();
                            getParentNodes(node, allNode);
                        }
                        //反转
                        var gjhyStr = "";
                        var nodeArrs = allNodesStr.split("-");
                        for (var i = nodeArrs.length - 1; i >= 0; i--) {
                            gjhyStr += nodeArrs[i] + "-";
                        }
                        gjhyStr = gjhyStr.substring(0, gjhyStr.lastIndexOf("-"));
                        $("#" + treeId + "Conten").val(gjhyStr);

                        // 根据treeId判断是然后进行页面渲染
                        if (treeId == "cyjgtree") {
                            // 产业结构调整指导目录树
                            $("#cyjgmlStr").val(gjhyStr);
                            $("#cyjgml").attr("value", treeNode.id)
                        }
                    }
                }else{
                    // ------------------------------
                    var nodes = treeObj.getSelectedNodes();
                    if (nodes[0].level != 0) {
                        if (nodes.length > 0) {
                            var allNode = nodes[0]['name'];
                            //获取当前选中节点
                            var node = nodes[0].getParentNode();
                            getParentNodes(node, allNode);
                        }
                        //反转
                        var gjhyStr = "";
                        var nodeArrs = allNodesStr.split("-");
                        for (var i = nodeArrs.length - 1; i >= 0; i--) {
                            gjhyStr += nodeArrs[i] + "-";
                        }
                        gjhyStr = gjhyStr.substring(0, gjhyStr.lastIndexOf("-"));
                        $("#" + treeId + "Conten").val(gjhyStr);

                        // 根据treeId判断是然后进行页面渲染
                        if (treeId == "cyjgtree") {
                            // 产业结构调整指导目录树
                            $("#cyjgmlStr").val(gjhyStr);
                            $("#cyjgml").attr("value", treeNode.id)
                        }
                    }
                    //alert("无子节点！")
                }
            } else {
                alert(res.message);
            }
        },
    });


}

function zTreeOnClick(event, treeId, treeNode) {

    //获取选中的节点
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    // ------国际行业只能选择4级---------
    if(treeId == 'gjhytree'){
        if(treeNode.isParent) {
            alert('请选择四级栏目！')
            return;
        }
        treeObj.checkNode(treeNode, !treeNode.checked, true);
    }
    //所属领域只能选择二级
    if(treeId == 'sslytree'){
        if(treeNode.isParent) {
            alert('请选择二级栏目！')
            return;
        }
        treeObj.checkNode(treeNode, !treeNode.checked, true);
    }
    // ------------------------------
    var nodes = treeObj.getSelectedNodes();
    if (nodes[0].level != 0) {
        if (nodes.length > 0) {
            var allNode = nodes[0]['name'];
            //获取当前选中节点
            var node = nodes[0].getParentNode();
            getParentNodes(node, allNode);
        }
        //反转
        var gjhyStr = "";
        var nodeArrs = allNodesStr.split("-");
        for (var i = nodeArrs.length - 1; i >= 0; i--) {
            gjhyStr += nodeArrs[i] + "-";
        }
        gjhyStr = gjhyStr.substring(0, gjhyStr.lastIndexOf("-"));
        $("#" + treeId + "Conten").val(gjhyStr);

        // 根据treeId判断是然后进行页面渲染
        if (treeId == "gjhytree") {
            // 国际行业树
            $("#gjhyStrShow").val(gjhyStr);
            $("#gjhy").attr("value", treeNode.id)
        } else if (treeId == "sshytree") {
            // 所属行业树
            $("#sshyStr").val(gjhyStr);
            $("#sshy").attr("value", treeNode.id)
        } else if (treeId == "cyjgtree") {
            // 产业结构调整指导目录树
            $("#cyjgmlStr").val(gjhyStr);
            $("#cyjgml").attr("value", treeNode.id)
        }else if (treeId == "sslytree") {
            // 产业结构调整指导目录树
            $("#sslyStr").val(gjhyStr);
            $("#ssly").attr("value", treeNode.id)
        }
    }
};

//获取父节点文本
function getParentNodes(node, allNode) {
    if (node != null) {
        allNode += "-" + node['name'];
        curNode = node.getParentNode();
        getParentNodes(curNode, allNode);
    } else {
        //根节点
        allNodesStr = allNode;
    }
}


//查找树节点
function searchNode(textIdStr, treeId) {
    nodeList = [];
    index_i = 0;
    var keyValue = $('#' + textIdStr).val();
    if (keyValue) {
        var treeObj = $.fn.zTree.getZTreeObj(treeId);
        nodeList = treeObj.getNodesByParamFuzzy("name", keyValue, null);
        if (nodeList && nodeList.length > 0) {
            treeObj.selectNode(nodeList[0]);
            treeObj.expandNode(nodeList[0], true, true, true);
        }
    }
}

/**
 * 查询字典接口
 * @param coding
 * @returns {*}
 */
function getDictionary(coding) {
    let dicData;
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/info?coding=" + coding + "&pages=1&rows=99999",
        success: function (res, status) {
            if (res.code === 200) {
                dicData = res.data.data;
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    return dicData;
}

/**
 * 查询字典接口
 * @param coding
 * @param pages
 * @param rows
 * @returns {*}
 */
function getDictionaryParams(coding, pages, rows) {
    let dicData;
    $.ajax({
        type: "GET",
        async: false,
        url: gatewayUrl + "/report/dictionary/category/info",
        data: {
            coding: coding,
            pages: pages,
            rows: rows,
        },
        success: function (res, status) {
            if (res.code === 200) {
                dicData = res.data.data;
                console.log(dicData.length, 999)
            } else {
                alert(res.message);
                return [];
            }
        },
    });
    return dicData;
}

// dxh
// 审批类型
var type = " ";
var newType = "SHEN_PI";

// 行政地区编码
var divisionCode = "540000";

// 获取页面路径 url 参数
function getParamter(variable) {
    var newUrl = window.location.href;
    var index = newUrl.lastIndexOf(variable);
    var jumpUrl = newUrl.substring(index + 5, newUrl.length);

    /*let query = window.location.href.split("?")[1];
    let vars = query.split("&");

    for (let i = 0; i < vars.length; i++) {
        let pair = vars[i].split("=")
        if (pair[0] == variable) {
            return pair[1]
        }
    }*/
    return jumpUrl;
}

// 获取当前所选的审批类型
function getspType() {
    var c = $(".tabs li");
    var type = "";
    for (var i = 0; i < c.length; i++) {
        if ($(c[i]).is(".selected")) {
            if ($(c[i]).text() == "投资项目备案") {
                type = "BEI_AN"
            } else if ($(c[i]).text() == "投资项目核准") {
                type = "HE_ZHUN"
            } else {
                type = "SHEN_PI"
            }
        }
    }
    return type;
}

// 通过地区编码跟审批类型展示内容 - 接口
function getCodeAndType(type, divisionCode) {
    console.log(type, 123)
    if (type == "HE_ZHUN") {
        $.ajax({
            type: "GET",
            // url: gatewayUrl + "/report/" + type + "/area/" + divisionCode,
            url: gatewayUrl + '/report/report/ML/' + type + "/area/" + divisionCode,
            success: function (res, status) {
                if (res.code == 200) {
                    var type = "HE_ZHUN";
                    if (res.data != null) {
                        console.log(res.data.length)
                        $('#area_sp').html('');
                        for (var i = 0; i < res.data.length; i++) {
                            if (res.data[i].permitItemBaseInfoDTOList == null) {
                                // var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;"></span><span>' + '暂时没有数据' + '</span></div><button class="r button" onclick="showSbPage()">开始申报</button><button class="r button1" value="" onclick="getguideList()">办事指南</button></div>')
                                // var str2 = "暂时没有数据";
                                // $("#t" + i).after(str2);
                            } else {
                                var str1 = $('<div class="ss_box"><h4 class="ss_title" id="t' + i + '">' + res.data[i].permitItemName + '</h4></div>')
                                $('#area_sp').append(str1);
                                for (var j = 0; j < res.data[i].permitItemBaseInfoDTOList.length; j++) {
                                    var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;">' + '[' + res.data[i].permitItemBaseInfoDTOList[j].divisionName + ']' + '</span><span>' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '</span></div><button class="r button" onclick="showSbPage(\'' + type + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionCode + '\',\'' + res.data[i].permitItemName + '\')">开始申报</button><button class="r button1" value="\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\'" onclick="getguideList(type,divisionCode,\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\')">办事指南</button></div>')
                                    $("#t" + i).after(str2);
                                }
                            }
                        }
                    }
                }
            },
        });
    } else {
        $.ajax({
            type: "GET",
            url: gatewayUrl + "/report/report/cat/" + type + "/area/" + divisionCode,
            success: function (res, status) {
                if (res.code == 200) {
                    if (res.data != null) {
                        $('#area_sp').html('');
                        for (var i = 0; i < res.data.length; i++) {
                            if (res.data[i].permitItemBaseInfoDTOList == null) {
                                // var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;"></span><span>' + '暂时没有数据' + '</span></div><button class="r button" onclick="showSbPage()">开始申报</button><button class="r button1" value="" onclick="getguideList()">办事指南</button></div>')
                                // var str2 = "暂时没有数据";
                                // $("#t" + i).after(str2);
                            } else {
                                var str1 = $('<div class="ss_box"><h4 class="ss_title" id="t' + i + '">' + res.data[i].permitItemName + '</h4></div>')
                                $('#area_sp').append(str1);
                                for (var j = 0; j < res.data[i].permitItemBaseInfoDTOList.length; j++) {
                                    var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;">' + '[' + res.data[i].permitItemBaseInfoDTOList[j].divisionName + ']' + '</span><span>' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '</span></div><button class="r button" onclick="showSbPage(\'' + type + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionCode + '\',\'' + res.data[i].permitItemName + '\')">开始申报</button><button class="r button1" value="\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\'" onclick="getguideList(type,divisionCode,\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\')">办事指南</button></div>')
                                    $("#t" + i).after(str2);
                                }
                            }
                        }
                    }
                }
            },
        });
    }

}

// 点击审批类型, 判断是地区还是分类
function tabBoxToggle(typeSp, t) {
    type = typeSp;
    newType = typeSp;
    $('.tabs').children('li').removeClass('selected')
    $(t).addClass('selected')
    if (divisionCode == "" || divisionCode == null) {
        divisionCode = "540000"
    }

    console.log($(".sidebar_tab div:first").is(".selected2"), 888)

    if ($(".sidebar_tab div:first").is(".selected2")) {

        getCodeAndType(type, divisionCode);
    } else {

        getHangyeType(type)
    }
}

// 点击地区/分类,获取当前选择的类型
function byToggle(t) {
    $('.sidebar_tab div').removeClass('selected2');
    $(t).addClass('selected2');
    type = getspType();
    if ($(".sidebar_tab div:first").is(".selected2")) {
        $('.flleft-warp .flleft').css('background-color', '#f8f8f8');
        $('#app2').addClass("dsn")
        $("#app").removeClass("dsn")
        getCodeAndType(type, divisionCode);
    } else {
        $('.flleft-warp .flleft').css('background-color', '#fff');
        $('#app').addClass("dsn")
        $("#app2").removeClass("dsn")
        getHangyeType(type)
    }

}

// 西藏的行政区划zTree数据 节点点击事件
function zTreeOnClickregion(event, treeId, treeNode) {
    console.log(treeNode.name, 555)
    // 获取id 为 treeId 的zTree对象
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    // 获取当前被选中的节点集合
    var nodes = treeObj.getSelectedNodes(true);
    var ids = [];
    for (var i = 0; i < nodes.length; i++) {
        ids.push(nodes[i].id)
    }
    divisionCode = ids.pop();

    type = getspType();
    getCodeAndType(type, divisionCode);
}

// 获取办事指南列表
function getguideList(type, divisionCode, catalogUuid) {
    // 需要跳转到bszn1的页面
    type = getspType();
    if (inThymeleaf()) {
        $(window).attr('location', "/report/workInfo/ProjectReport/Guide?type=" + type + "&divisionCode=" + divisionCode + "&catalogUuid=" + catalogUuid);
    } else {
        $(window).attr('location', "/templates/officehall/bszn/bszn1.html?type=" + type + "&divisionCode=" + divisionCode + "&catalogUuid=" + catalogUuid);
    }
    console.log(type, divisionCode, catalogUuid, 2)
}


// 根据大分类获取下面的行业分类 [点击分类]
function getHangyeType(type) {
    // $('#app').addClass("dsn")
    // $("#app2").removeClass("dsn")
    type = getspType();
    $('#area_sp').html(" ");
    $('#app2').html(" ");
    $.ajax({
        type: "GET",
        url: gatewayUrl + "/report/report/cat/" + type,
        success: function (res) {
            if (res.code == 200) {
                if (res.data != null) {
                    $("#app2").html("");
                    let liO = '';
                    $.each(res.data, function (index, item) {
                        if (index === 0) {
                            queryHangyeAndType(res.data[0].permitIndustry);
                            liO = '<ul ><li style="background-color: rgb(17, 131, 219);color:rgb(255, 255, 255);" onclick="queryHangyeAndType(\'' + item.permitIndustry + '\',this)">' + item.permitItemName + '</li></ul>';
                        } else {
                            liO = '<ul ><li onclick="queryHangyeAndType(\'' + item.permitIndustry + '\',this)">' + item.permitItemName + '</li></ul>';
                        }

                        $("#app2").append(liO)
                    })
                }
            }
        }
    })
}

// 根据行业分类查询审批类别
// function queryHangyeAndType(type, industry) {
function queryHangyeAndType(industry, t) {
    console.log("type:" + getspType(), industry, 1112)

    $("#app2 ul li").css({ "background-color": '#fff', "color": "#606266" });
    if (t) {
        $(t).css({ "background-color": '#1183db', "color": "#fff" });
    }

    var type = getspType();
    var divisionCode = "540000";
    $('#area_sp').html('');
    $.ajax({
        type: "GET",
        url: gatewayUrl + "/report/report/cat/" + type + "/industry/" + industry + "/area/" + divisionCode,
        success: function (res) {
            if (res.code == 200) {
                if (res.data == null) {
                    var str1 = $('<div class="ss_box">暂时没有数据</div>')
                    // var str1 = $('<div class="ss_box"><div class="ss_content"><div class="long_string" style="line-height:30px"><span style="color:#5086CF;">' + '[区/县]' + '</span><span>区（县）级项目申报</span></div><button class="r button" onclick="showSbPage()">开始申报</button><button class="r button1" value="" onclick="getguideList()">办事指南</button></div></div>')
                    // var str1 = $('<div class="ss_box"><div class="ss_content"><div class="long_string" style="line-height:30px"><span style="color:#5086CF;">' + '[区/县]' + '</span><span>区（县）级项目申报</span></div><button class="r button">开始申报</button><button class="r button1" value="">办事指南</button></div></div>')
                    $('#area_sp').append(str1);
                } else if (res.data != null) {
                    for (var i = 0; i < res.data.length; i++) {
                        var str1 = $('<div class="ss_box"><h4 class="ss_title" id="thy">' + res.data[i].permitItemName + '</h4></div>')
                        $('#area_sp').append(str1);
                        if (res.data[i].permitItemBaseInfoDTOList == null) {
                            /**var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;">' + '[区/县]' + '</span><span>区（县）级项目申报</span></div><button class="r button">开始申报</button><button class="r button1" value="">办事指南</button></div>')*/
                            var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;">' + '[区/县]' + '</span><span>区（县）级项目申报</span></div><button class="r button">开始申报</button></div>')
                            $("#thy").after(str2);
                        } else {
                            for (var j = 0; j < res.data[i].permitItemBaseInfoDTOList.length; j++) {
                                // var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;">' + '[' + res.data[i].permitItemBaseInfoDTOList[j].divisionName + ']' + '</span><span>' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '</span></div><button class="r button" onclick="showSbPage(\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionCode + '\')">开始申报</button><button class="r button1" value="\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\'" onclick="getguideList(type,divisionCode,\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\')">办事指南</button></div>')
                                var str2 = $('<div class="ss_content"><div class="long_string"><span style="color:#5086CF;">' + '[省]' + '</span><span>' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '</span></div><button class="r button" onclick="showSbPage(\'' + type + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionName + '\',\'' + res.data[i].permitItemBaseInfoDTOList[j].divisionCode + '\',\'' + res.data[i].permitItemName + '\')">开始申报</button><button class="r button1" value="\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\'" onclick="getguideList(type,divisionCode,\'' + res.data[i].permitItemBaseInfoDTOList[j].permitItemCode + '\')">办事指南</button></div>')
                                $("#thy").after(str2);
                            }
                        }
                    }
                }
            }
        }
    })

    if ($(document).scrollTop() > 0) {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
    }
}


// 开始申报
function showSbPage(type, catalogUuid, permitItemName, divisionName, divisionCode, permitItem) {
    console.log("type审批类型:" + type, "catalogUuid:" + catalogUuid, "permitItemName审批目录:" + permitItemName, "divisionName审批目录级别:" + divisionName, "divisionCode行政区划码:" + divisionCode, "permitItemName目录分类:" + permitItem)

    $("#myModal").modal("show");

    $('#myModal').on('shown.bs.modal', function (event) {
        console.log(event, 888)
        let modal = $(this);
        modal.find(".modal-content").css({ "height": "180px" })
        modal.find(".modal-header").css({ "height": "40px", "background-color": "#487ab7", "color": "#fff" })
        modal.find(".modal-body").css({ "height": "80px" })
        modal.find(".modal-footer").css({ "padding-top": "15px" })
        modal.find(".modal-body").html("");
        let divtext = '<span style="font-size:16px;color:black;">请您确认您的项目是否由<span style="color:red;">[' + divisionName + ']</span>' + '发改委或相关部门核准,' + '如不是请重新选择审批层级！</span>';
        modal.find(".modal-body").append(divtext)
    })

    $('#myModal2').on('shown.bs.modal', function (event) {
        console.log(event, 888)
        let modal = $(this);
        modal.find(".modal-content").css({ "height": "160px" })
        modal.find(".modal-header").css({ "height": "40px", "background-color": "#487ab7", "color": "#fff" })
        modal.find(".modal-body").css({ "height": "60px", "text-align": "center" })
        modal.find(".modal-footer").css({ "padding-top": "15px" })
        modal.find(".modal-body").html("");
        let divtext = '<span style="font-size:16px;color:black;">请确认您的项目是否是<span style="color:red;">[' + '外商投资' + ']</span>项目</span>';
        modal.find(".modal-body").append(divtext)
    })

    if (type == "SHEN_PI") {
        $("#makeSure").bind('click', function () {
            gosbPage(type, catalogUuid, permitItemName, divisionName, divisionCode, permitItem); //跳转申报页面
        })
    } else {
        $("#makeSure").bind('click', function () {
            $("#myModal").modal("hide");
            $("#myModal2").modal("show");
            $("#yes").bind('click', function () {
                gosbWSPage(type, catalogUuid, permitItemName, divisionName, divisionCode, permitItem);//外商
            })
            $("#no").bind('click', function () {
                gosbPage(type, catalogUuid, permitItemName, divisionName, divisionCode, permitItem); //跳转申报页面
            })
        })
    }
}

function gosbPage(type, catalogUuid, permitItemName, divisionName, divisionCode, permitItem) {
    setStore("divisionName", divisionName)
    if (inThymeleaf()) {
        window.location.href = encodeURI("/report/workInfo/ProjectReport/ShenPi/1?type=" + type + "&catalogUuid=" + catalogUuid + "&permitItemName=" + permitItemName + "&divisionName=" + divisionName + "&divisionCode=" + divisionCode + "&permitItem=" + permitItem)
    } else {
        window.location.href = encodeURI("/templates/officehall/xmsb/spsb1.html?type=" + type + "&catalogUuid=" + catalogUuid + "&permitItemName=" + permitItemName + "&divisionName=" + divisionName + "&divisionCode=" + divisionCode + "&permitItem=" + permitItem)
    }
}

function gosbWSPage(type, catalogUuid, permitItemName, divisionName, divisionCode, permitItem) {
    if (inThymeleaf()) {
        window.location.href = encodeURI("/report/workInfo/ProjectReport/ShenPi/Foreign/1?type=" + type + "&catalogUuid=" + catalogUuid + "&permitItemName=" + permitItemName + "&divisionName=" + divisionName + "&divisionCode=" + divisionCode + "&permitItem=" + permitItem)
    } else {
        window.location.href = encodeURI("/templates/officehall/xmsb/wssb1.html?type=" + type + "&catalogUuid=" + catalogUuid + "&permitItemName=" + permitItemName + "&divisionName=" + divisionName + "&divisionCode=" + divisionCode + "&permitItem=" + permitItem)
    }
}

function getSessionStore(name) {
    if (window.sessionStorage) {
        return window.sessionStorage.getItem(name);
    } else {
        alert('此浏览器不支持「SessionStorage」技术,请更换浏览器尝试');
    }
}

